# Description: Load data from csv files
# Author: Shibo Li, MiQroEra Inc.
# Date: 2023-08-21
# License: MIT License
# Version: 1.0


import csv


def load_codon_usage_table(filepath):
    codon_table = {}
    with open(filepath) as f:
        reader = csv.reader(f)
        next(reader)
        for row in reader:
            codon, aa, prob = row
            aa = aa.upper()
            codon = codon.upper()
            if aa not in codon_table:
                codon_table[aa] = {}
            codon_table[aa][codon] = float(prob)

    return codon_table


if __name__ == "__main__":
    filepath = "data/codon_usage/Caenorhabditis_elegans.csv"
    codon_table = load_codon_usage_table(filepath)
    print(codon_table)
